from uf import UF

with open("out.txt", 'r') as f:
    print f
    data=[map(int, line.split()) for line in f]

icount = data.pop(0);
print icount

myuf = UF(icount[0])
while(myuf.curCluster() != 4):
    line = data.pop(0)
    myuf.weighted_union(line[0]-1,line[1]-1)
    print line
    print myuf.curCluster()

curline = data.pop(0)
while(myuf.quick_find(curline[0]-1,curline[1]-1)):
    curline = data.pop(0)

print curline[2]



